﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ArchiveEdit.ascx.cs" Inherits="CentralOffice.WebClient.Archives.ArchiveEdit" %>

<asp:ObjectDataSource ID="odsCategory" runat="server" SelectMethod="GetAll" TypeName="CentralOffice.Archive.BusinessActions.ArchiveCategory" DeleteMethod="Delete"></asp:ObjectDataSource>
<script type="text/javascript" src="../inc/js/ProvinceCity.js"></script>
<table class="TableBlock" width="90%" align="center">
<tr>
    <td class="TableData" width=15%>项目名称：</td><td class="TableData" width=35%><asp:TextBox ID="txtName" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="必须填写档案标题" ControlToValidate="txtName">*</asp:RequiredFieldValidator><span class="warning">(必填)</span></td>
    <td class="TableData" width=15%>档案类型：</td><td class="TableData" width=35%><asp:DropDownList ID="ddlCategory" DataSourceID="odsCategory" DataTextField="Name" DataValueField="Id" runat="server" EnableViewState="false"></asp:DropDownList></td>
</tr>
<tr>
    <td class="TableData">序号：</td><td class="TableData"><asp:TextBox ID="txtOrderNumber" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">密级：</td><td class="TableData"><asp:DropDownList ID="ddlSecretLevel" runat="server"></asp:DropDownList></td>   
</tr>
<tr>
    <td class="TableData">档案编号：</td><td class="TableData"><asp:TextBox ID="txtCode" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">省份：</td><td class="TableData"><select id="province" name="province"></select><asp:HiddenField ID="txtProvince" runat="server" EnableViewState="false" /> </td>   
</tr>
<tr>
    <td class="TableData">合同号：</td><td class="TableData"><asp:TextBox ID="txtContractCode" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">市县：</td><td class="TableData"><select id="city" name="city"></select><asp:HiddenField ID="txtCity" runat="server" EnableViewState="false" /></td>  
</tr>
<tr>
    <td class="TableData">档案关键字：</td><td class="TableData"><asp:TextBox ID="txtKeyWords" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">设计年份：</td><td class="TableData"><asp:TextBox ID="txtDesignedYear" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>

<tr>
    <td class="TableData">结构形式：</td><td class="TableData"><asp:TextBox ID="txtConstructForm" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">存档日期：</td><td class="TableData"><asp:TextBox ID="txtFiledDate" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox>&nbsp;<img onclick="WdatePicker({el:$dp.$('txtFiledDate'), dateFmt:'yyyy-MM-dd'})" src="../inc/js/My97DatePicker/skin/datePicker.gif" width="16" height="22" align="absmiddle" /><asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="必须填写归档日期" ControlToValidate="txtFiledDate">（必填）</asp:RequiredFieldValidator></td>
</tr>
<tr>
    <td class="TableData">客户名称：</td><td class="TableData"><asp:TextBox ID="txtCustomer" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="必须填写客户" ControlToValidate="txtCustomer">*</asp:RequiredFieldValidator><span class="warning">(必填)</span></td>
    <td class="TableData">联系人：</td><td class="TableData"><asp:TextBox ID="txtContact" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
</tr>
<tr>
    <td class="TableData">电话：</td><td class="TableData"><asp:TextBox ID="txtTelephone1" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox><%--<span class="warning">(必填)</span>--%></td>
    <td class="TableData">地址：</td><td class="TableData"><asp:TextBox ID="txtAddress" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
</tr>
<tr>
    <td class="TableData">规模：</td><td class="TableData"><asp:TextBox ID="txtScale" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">设计阶段：</td><td class="TableData"><asp:TextBox ID="txtDesignStage" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>
<tr>
    <td class="TableData">所属片区：</td><td class="TableData"><asp:TextBox ID="txtBelongedTo" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">项目经理：</td><td class="TableData"><asp:TextBox ID="txtProjectManager" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>
<tr>
    <td class="TableData">土建图纸：</td><td class="TableData"><asp:FileUpload ID="fileBuildingBlueprint" runat="server" /><asp:Literal ID="lblBuildingBlueprint" EnableViewState="false" runat="server"></asp:Literal></td>
    <td class="TableData">电气图纸：</td><td class="TableData"><asp:FileUpload ID="fileElectricalBlueprint" runat="server" /><asp:Literal ID="lblElectricalBlueprint" EnableViewState="false" runat="server"></asp:Literal></td>  
</tr>
<tr>
    <td class="TableData">机械材料清单：</td><td class="TableData"><asp:FileUpload ID="fileMechanicalMaterialManifest" runat="server" /><asp:Literal ID="lblMechanicalMaterialManifest" EnableViewState="false" runat="server"></asp:Literal></td>
    <td class="TableData">电气材料清单：</td><td class="TableData"><asp:FileUpload ID="fileElectricalMaterialManifest" runat="server" /><asp:Literal ID="lblElectricalMaterialManifest" EnableViewState="false" runat="server"></asp:Literal></td>  
</tr>
<tr>
    <td class="TableData">电气方案：</td><td class="TableData"><asp:FileUpload ID="fileSystemSolution" runat="server" /><asp:Literal ID="lblSystemSolution" EnableViewState="false" runat="server"></asp:Literal></td>
    <td class="TableData">整体方案：</td><td class="TableData"><asp:FileUpload ID="fileElectricalSolution" runat="server" /><asp:Literal ID="lblElectricalSolution" EnableViewState="false" runat="server"></asp:Literal></td>  
</tr>

<tr>
    <td class="TableData">效果图：</td><td class="TableData"><asp:FileUpload ID="fileDesignSketch" runat="server" /><asp:Literal ID="lblDesignSketch" EnableViewState="false" runat="server"></asp:Literal></td>
    <td class="TableData">招投标文件：</td><td class="TableData"><asp:FileUpload ID="fileTenderDocumentation" runat="server" /><asp:Literal ID="lblTenderDocumentation" EnableViewState="false" runat="server"></asp:Literal></td>  
</tr>
<tr>
    <td class="TableData">初设报告：</td><td class="TableData"><asp:FileUpload ID="filePreliminaryDesign" runat="server" /><asp:Literal ID="lblPreliminaryDesign" EnableViewState="false" runat="server"></asp:Literal></td>
    <td class="TableData">其他附件：</td><td class="TableData"><asp:FileUpload ID="fileOtherDocumentation" runat="server" /><asp:Literal ID="lblOtherDocumentation" EnableViewState="false" runat="server"></asp:Literal></td>  
</tr>


<tr>
    <td class="TableData">执行人：</td><td class="TableData" colspan="3">
    
    <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" RenderMode="Inline"><ContentTemplate>
    <input type="text" id="txtExecutorReadOnly" style="width:82%" name="txtExecutorReadOnly" class="SmallStatic" runat="server" readonly="readonly" /><asp:HiddenField ID="txtExecutor" runat="server" />&nbsp;<asp:LinkButton ID="LinkButton1" CommandName="Executor" runat="server" OnClick="btnShowPopup_Click" CssClass="orgAdd">选择</asp:LinkButton>
    </ContentTemplate><Triggers><asp:AsyncPostBackTrigger ControlID="btnOK" /></Triggers></asp:UpdatePanel>&nbsp;<a href="javascript:;" class="orgClear" onclick="$get('<%= txtExecutorReadOnly.ClientID %>').value='';$get('<%= txtExecutor.ClientID %>').value='';">清空</a>
    
    
    </td>
</tr>

<tr>
    <td class="TableData">备注：</td><td class="TableData" colspan="3"><asp:TextBox ID="txtRemark" runat="server" CssClass="BigInput"  style="width:80%;"></asp:TextBox></td>
</tr>

<tr align="center" class="TableControl">
    <td colspan="4">
        <asp:Button ID="btnQuery" runat="server" Text="保存"  CssClass="BigButton" OnClick="btnSave_Click" OnClientClick="return clientCheck();" />
        <asp:Button ID="btnContinue" runat="server" Text="保存并继续添加" CssClass="BigButton" style="margin-left:65px;"  OnClick="btnContinue_Click" />
        <input type="reset" value="重置" class="BigButton" style="margin-left:65px;" />
        <input type="button" value="取消" class="BigButton" style="margin-left:65px;" onclick="history.back();" />
    </td>
</tr>
</table>



<asp:Literal ID="lblJavaScript" EnableViewState="false" runat="server"></asp:Literal>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableViewState="false" />


	<asp:Panel ID="pnlPopup" runat="server" CssClass="x-pne" style="display:none; width:460px;">
    <asp:UpdatePanel ID="updPnlDepartment" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    
    <asp:HiddenField ID="txtSelectedObject" runat="server" />
    <asp:Button id="btnShowEdit" runat="server" style="display:none" />
    <ajaxToolKit:ModalPopupExtender ID="mdlDetailView" runat="server" 
        BehaviorID="detailView" 
        TargetControlID="btnShowEdit" 
        PopupControlID="pnlPopup" 
        CancelControlID="btnClose" BackgroundCssClass="modalBackground" 
        PopupDragHandleControlID="pnlDrag" />
        
    <asp:Panel ID="pnlDrag" runat="server" CssClass="corner-bg x-pne-lt x-pne-left">
        <div class="corner-bg x-pne-rt x-pne-right">
            <div class="corner-bg x-pne-t dragTitle">
                <div class="x-pne-btn" id="Div1" onclick="$find('detailView').hide();"></div>
                <div class="x-pne-caption font dragTitle"><span>请选择执行人</span></div>
            </div>
        </div>
    </asp:Panel>

    <div>
    
        <div class="side-bg x-pne-l">
            <div class="side-bg x-pne-r">
                <div class="x-pne-c" style="WIDTH: 448px;">
					<div style="margin:10px;font-size:9pt;" class="wrapper">
					
<div id="div2" style="width:430px;height:300px; overflow:auto;">
<asp:TreeView ID="tvEmp" runat="server" EnableViewState="true" OnLoad="tvEmp_Load"></asp:TreeView>
</div>
                    <!-- 下面是确认按钮 -->
                    <div style="width:328px; margin-top:16px;">
                        <table  style="width:100%; margin-left:40px;">
                            <tr>
                                <td>
<div class="btn-side btn-bg"></div>
<div class="btn-body btn-bg" style="background-position: 0px 168px; width: 66px"><asp:Button ID="btnOK" runat="server" Text="  确定  " CssClass="font" OnClick="btnOK_Click" /></div>
<div class="btn-side btn-bg" style="background-position: 0px 189px"></div>

                                </td>
                                <td>
<div class="btn-side btn-bg"></div>
<div class="btn-body btn-bg" style="background-position: 0px 168px; width: 66px;"><asp:Button ID="btnClose" runat="server" Text="  取消  " CssClass="font" /></div>
<div class="btn-side btn-bg" style="background-position: 0px 189px"></div>
                                </td>
                            </tr>
                        </table>
                    </div>
                        
					</div>
                </div>
            </div>
        </div>

        <div class="corner-bg x-pne-lb x-pne-left">
            <div class="corner-bg x-pne-rb x-pne-right">
                <div class="corner-bg x-pne-b"></div>
            </div>
        </div>
        
    </div>
    
    </ContentTemplate>
    </asp:UpdatePanel>
</asp:Panel>

<asp:updateprogress id="updateProgress"  runat="server">
    <progresstemplate>
        <div id="progressBackgroundFilter"></div>
        <div id="processMessage">正在处理数据，请稍等...<br /><br /><img alt="Loading" src="../images/loading_16.gif" /></div>
    </progresstemplate>
</asp:updateprogress>

<script type="text/javascript" >
    var provinceElement = document.getElementById("province");
    var cityElement = document.getElementById("city");
    populateProvince(document.getElementById("province"), document.getElementById("city"));

    var currentProvinceName = document.getElementById("<%=txtProvince.ClientID %>").value;
    var currentCityName = document.getElementById("<%=txtCity.ClientID %>").value;

    //alert(currentProvinceName + currentCityName);

    if (currentProvinceName.length > 0 && jQuery) {
        var archiveId = jQuery.getQueryString({ id: "id" });
        if (archiveId.length > 0) {
            var selectedIndex = 0;
            for (var i = 0; i < provinceElement.options.length; i++) {
                
                if (currentProvinceName == provinceElement.options[i].innerText) {
                    provinceElement.selectedIndex = i;
                    //tmpProvince = provinceElement.options[i].value;
                    selectedIndex = i;
                    break;
                }
            }
            //alert(city[selectedIndex]);
            //alert(provinceElement.options[selectedIndex].value);
            populateCity(cityElement, city[selectedIndex], provinceElement.options[selectedIndex].value);

            for (var i = 0; i < cityElement.options.length; i++) {
                if (currentCityName == cityElement.options[i].innerText) {
                    cityElement.selectedIndex = i;
                    break;
                }
            }
        
        }
    }
    

    function clientCheck() {
        var provinceName = province[document.getElementById("province").value - 1];
        var cityNames = city[document.getElementById("province").value - 1]; //
        var cityName = cityNames[document.getElementById("city").value % 1000];

        document.getElementById("<%=txtProvince.ClientID %>").value = provinceName;
        document.getElementById("<%=txtCity.ClientID %>").value = cityName;
        
//        alert(document.getElementById("province").value);
//        alert(provinceName);
//        alert(document.getElementById("city").value);
//        alert(cityNames);
        //        alert(cityName);
        if (!notEmpty(document.getElementById('<%= txtName.ClientID  %>')))
        {
            alert("项目名称不能为空");
            return false;
        }
        if (!notEmpty(document.getElementById('<%= txtCustomer.ClientID  %>'))) {
            alert("客户名称不能为空");
            return false;
        }
        
        var startDate = document.getElementById('<%= txtFiledDate.ClientID  %>');
        if (!isDate(startDate)) {
            alert('存档日期格式不正确！');
            return false;
        }

        if (!isInteger(document.getElementById('<%= txtOrderNumber.ClientID  %>').value)) {
            alert('序号必须为正整数！');
            return false;
        }

        if (!isInteger(document.getElementById('<%= txtScale.ClientID  %>').value)) {
            alert('规模必须为正整数！');
            return false;
        }
    }

    function OnTreeNodeChecked() {
        var ele = window.event.srcElement;
        if (ele.type == 'checkbox') {
            var childrenDivID = ele.id.replace('CheckBox', 'Nodes');
            var div = document.getElementById(childrenDivID);
            if (div == null) return;
            var checkBoxs = div.getElementsByTagName('INPUT');
            for (var i = 0; i < checkBoxs.length; i++) {
                if (checkBoxs[i].type == 'checkbox')
                    checkBoxs[i].checked = ele.checked;
            }
        }
    }
    
</script>

<%--
<tr>
    <td class="TableData">土建图纸：</td><td class="TableData"><asp:TextBox ID="TextBox15" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">电气图纸：</td><td class="TableData"><asp:TextBox ID="TextBox16" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>
<tr>
    <td class="TableData">机械材料清单：</td><td class="TableData"><asp:TextBox ID="TextBox17" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">电气材料清单：</td><td class="TableData"><asp:TextBox ID="TextBox18" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>
<tr>
    <td class="TableData">电气方案：</td><td class="TableData"><asp:TextBox ID="TextBox19" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>
    <td class="TableData">整体方案：</td><td class="TableData"><asp:TextBox ID="TextBox20" runat="server" CssClass="BigInput" style="width:60%;"></asp:TextBox></td>  
</tr>--%>